$ git push
To https://github.com/jackey10055206/test.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://github.com/jackey10055206/test.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
$ git pull
remote: Enumerating objects: 6, done.
remote: Counting objects: 100% (6/6), done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 4 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (4/4), done.
From https://github.com/jackey10055206/test
3bd6182..9d0d18f master -> origin/master
Merge made by the 'recursive' strategy.
123.txt | 1 +
1 file changed, 1 insertion(+)
$ git push
Enumerating objects: 9, done.
Counting objects: 100% (8/8), done.
Delta compression using up to 8 threads
Compressing objects: 100% (4/4), done.
Writing objects: 100% (5/5), 609 bytes | 609.00 KiB/s, done.
Total 5 (delta 0), reused 0 (delta 0)
To https://github.com/jackey10055206/test.git
9d0d18f..f77fa62 master -> master
沒錯,他會跟你說,你需要先使用git pull
你才能執行git push
所以我們上面介紹了一種"先拉在推"的方法嘛!
接下來我在跟你說一種"我是老大"的方法
git push -f
$ git push
To https://github.com/jackey10055206/test.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://github.com/jackey10055206/test.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
$ git push -f
Enumerating objects: 27, done.
Counting objects: 100% (27/27), done.
Delta compression using up to 8 threads
Compressing objects: 100% (17/17), done.
Writing objects: 100% (27/27), 4.05 KiB | 1.35 MiB/s, done.
Total 27 (delta 0), reused 0 (delta 0)
To https://github.com/jackey10055206/test.git
+ b1b9f61...2e1efe4 master -> master (forced update)
-f
意思就是強制
明天來講講git clone吧!